home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
Pascal Strings
/
ConstPString.h
< prev
next >
Wrap
Text File
|
2000-06-23
|
1KB
|
51 lines
// ConstPString.h
#ifndef ConstPString_h
#define ConstPString_h
#ifndef ConstData_h
#include "ConstData.h"
#endif
class ConstPString
{
private:
const uint8 *string;
operator=( const ConstPString& ); // This method intentionally left undefined.
public:
ConstPString( const uint8 *s )
: string( s )
{
Assert( s != 0 );
}
uint8 Length() const { return string[0]; }
const URange32 Range() const { return URange32( 0, Length() ); }
const uint8& operator[]( uint32 i ) const
{ Assert( i < Length() ); return string[i+1]; }
const ConstData Text() const { return ConstData( string+1, Length() ); }
const ConstData Head( uint32 size ) const { return Text().Head( size ); }
const ConstData Tail( uint32 position ) const { return Text().Tail( position ); }
const ConstData Middle( URange32 range ) const { return Text().Middle( range ); }
operator const uint8 *() const { return string; }
operator ConstData() const { return Text(); }
};
bool operator==( ConstPString a, ConstPString b );
bool operator< ( ConstPString a, ConstPString b );
bool operator<=( ConstPString a, ConstPString b );
inline bool operator!=( ConstPString a, ConstPString b ) { return !(a == b); }
inline bool operator> ( ConstPString a, ConstPString b ) { return !(a <= b); }
inline bool operator>=( ConstPString a, ConstPString b ) { return !(a < b); }
int32 Compare( ConstPString a, ConstPString b );
#endif